package me.sealer.proxy;

import net.sf.cglib.proxy.MethodInterceptor;
import net.sf.cglib.proxy.MethodProxy;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.lang.reflect.Method;

/**
 * @author sealer
 * @date 2016/10/10
 * @email 1178884049@qq.com
 */
public class MyCglibProxy implements MethodInterceptor {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Override
    public Object intercept(Object obj, Method method, Object[] args, MethodProxy methodProxy) throws Throwable {

        logger.debug("======before call the method : " + method.getName() + "======");
        Object result = methodProxy.invokeSuper(obj, args);
        logger.debug("======after call the method : " + method.getName() + "======");
        return result;
    }
}
